package top.yangbuyi.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * @description: 杨不易网站:www.yangbuyi.top
 * @program: yangbuyiopenHis2020
 * @ClassName: ServletUtils
 * @create: 2020-09-01 14:22
 * @author: yangbuyi
 * @since： JDK1.8
 * @ServletUtils: 客户端请求工具$
 **/

public class ServletUtils {
	  /**
	   * 获取request
	   */
	  public static HttpServletRequest getRequest()
	  {
			return getRequestAttributes().getRequest();
	  }

	  /**
	   * 获取response
	   */
	  public static HttpServletResponse getResponse()
	  {
			return getRequestAttributes().getResponse();
	  }

	  public static ServletRequestAttributes getRequestAttributes()
	  {
			RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
			return (ServletRequestAttributes) attributes;
	  }

}
